home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / dev / mui / MCC_SpeedBar.lha / MCC_SpeedBar / Developer / C / Examples / demo3.c < prev    next >
C/C++ Source or Header  |  2002-06-13  |  8KB  |  204 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/datatypes.h>
  5. #include <proto/muimaster.h>
  6. #include <clib/alib_protos.h>
  7. #include <mui/SpeedBar_mcc.h>
  8. #include <mui/SpeedBarCfg_mcc.h>
  9. #include <datatypes/pictureclass.h>
  10. #include <string.h>
  11. #include <stdio.h>
  12.  
  13. /***********************************************************************/
  14.  
  15. long __stack = 8192;
  16. struct Library *DataTypesBase;
  17. struct Library *MUIMasterBase;
  18.  
  19. /***********************************************************************/
  20.  
  21. #ifndef MAKE_ID
  22. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  23. #endif
  24.  
  25. /***********************************************************************/
  26.  
  27. struct MUIS_SpeedBar_Button buttons[] =
  28. {
  29.     {0, "_Get", "Get the disc.", 0, NULL},
  30.     {1, "Sa_ve", "Save the disc.", 0, NULL},
  31.     {2, "_Stop", "Stop the connection.", 0, NULL},
  32.     {MUIV_SpeedBar_Spacer},
  33.     {3, "_Disc", "Disc page.", 0, NULL},
  34.     {4, "_Matches", "Matches page.", 0, NULL},
  35.     {5, "_Edit", "Edit page.", 0, NULL},
  36.     {MUIV_SpeedBar_End},
  37. };
  38.  
  39. /***********************************************************************/
  40.  
  41. static Object *
  42. loadDTBrush(struct MyBrush *brush,STRPTR file)
  43. {
  44.     struct BitMapHeader *bmh;
  45.     register Object     *dto;
  46.  
  47.     if (!(dto = NewDTObject(file,DTA_GroupID,GID_PICTURE,PDTA_Remap,FALSE,PDTA_DestMode,PMODE_V42,TAG_DONE)) ||
  48.         !(DoMethod(dto,DTM_PROCLAYOUT,NULL,1)) ||
  49.         !(GetDTAttrs(dto,PDTA_DestBitMap,&brush->BitMap,PDTA_CRegs,&brush->Colors,PDTA_BitMapHeader,&bmh,TAG_DONE)==3))
  50.     {
  51.         if (dto)
  52.         {
  53.             DisposeDTObject(dto);
  54.             dto = NULL;
  55.         }
  56.         brush->BitMap = NULL;
  57.     }
  58.     else
  59.     {
  60.         brush->Width  = bmh->bmh_Width;
  61.         brush->Height = bmh->bmh_Height;
  62.     }
  63.  
  64.     return dto;
  65. }
  66.  
  67. /***********************************************************************/
  68.  
  69. #define TEMPLATE "STRIP,NUMBUTTON/N"
  70.  
  71. int
  72. main(int argc,char **argv)
  73. {
  74.     struct RDArgs   *ra;
  75.     LONG            arg[2] = {0};
  76.     int             res;
  77.  
  78.     if (ra = ReadArgs(TEMPLATE,arg,NULL))
  79.     {
  80.         if (DataTypesBase = OpenLibrary("datatypes.library",37))
  81.         {
  82.             if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  83.             {
  84.                 struct MyBrush                  stripBrush;
  85.                 Object                          *dto, *app, *win, *sb;
  86.                 Object                          *cfg, *update;
  87.                 struct MUIS_SpeedBarCfg_Config  c = {MUIV_SpeedBar_ViewMode_TextGfx, MUIV_SpeedBarCfg_Borderless|MUIV_SpeedBarCfg_Sunny};
  88.                 STRPTR                          stripName;
  89.  
  90.                 stripName = arg[0] ? (char *)arg[0] : "PROGDIR:Pics/Main.toolbar";
  91.  
  92.                 if (!(dto = loadDTBrush(&stripBrush,stripName)))
  93.                     printf("%s: warning can't load '%s'\n",argv[0],stripName);
  94.  
  95.                 if (app = ApplicationObject,
  96.                         MUIA_Application_Title,         "SpeedBar Demo3",
  97.                         MUIA_Application_Version,       "$VER: SpeedBarDemo3 14.4 (13.6.2002)",
  98.                         MUIA_Application_Copyright,     "Copyright 1999-2002 by Alfonso Ranieri",
  99.                         MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  100.                         MUIA_Application_Description,   "Speed(Bar|Button|BarCfg).mcc test",
  101.                         MUIA_Application_Base,          "SPEEDBARTEST",
  102.                         SubWindow, win = WindowObject,
  103.                             MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  104.                             MUIA_Window_Title,          "SpeedBar Demo3",
  105.                             WindowContents, VGroup,
  106.                                 Child, HGroup,
  107.                                     GroupFrame,
  108.                                     Child, sb = SpeedBarObject,
  109.                                         MUIA_Group_Horiz,               TRUE,
  110.                                         MUIA_SpeedBar_Borderless,       TRUE,
  111.                                         MUIA_SpeedBar_Sunny,            TRUE,
  112.                                         MUIA_SpeedBar_Buttons,          buttons,
  113.                                         MUIA_SpeedBar_StripUnderscore,  TRUE,
  114.                                         MUIA_SpeedBar_EnableUnderscore, TRUE,
  115.                                         MUIA_SpeedBar_BarSpacer,        TRUE,
  116.                                         MUIA_SpeedBar_StripBrush,       &stripBrush,
  117.                                         MUIA_SpeedBar_StripButtons,     arg[1] ? (*((ULONG *)arg[1])) : 14,
  118.                                     End,
  119.                                     Child, HSpace(0),
  120.                                 End,
  121.                                 Child, VSpace(0),
  122.                                 Child, VGroup,
  123.                                     GroupFrameT("Appareance"),
  124.                                     Child, cfg = SpeedBarCfgObject,
  125.                                         MUIA_SpeedBarCfg_Config, &c,
  126.                                     End,
  127.                                     Child, VSpace(0),
  128.                                     Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  129.                                 End,
  130.                                 Child, VSpace(0),
  131.                             End,
  132.                         End,
  133.                     End)
  134.                 {
  135.                     ULONG sigs = 0, id;
  136.  
  137.                     DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  138.                     DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  139.  
  140.                     set(win,MUIA_Window_Open,TRUE);
  141.  
  142.                     while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  143.                     {
  144.                         if (id==TAG_USER)
  145.                         {
  146.                             struct MUIS_SpeedBarCfg_Config *c;
  147.  
  148.                             get(cfg,MUIA_SpeedBarCfg_Config,&c);
  149.  
  150.                             SetAttrs(sb,MUIA_SpeedBar_ViewMode,c->ViewMode,
  151.                                         MUIA_SpeedBar_Borderless,c->Flags & MUIV_SpeedBarCfg_Borderless,
  152.                                         MUIA_SpeedBar_RaisingFrame,c->Flags & MUIV_SpeedBarCfg_Raising,
  153.                                         MUIA_SpeedBar_SmallImages,c->Flags & MUIV_SpeedBarCfg_SmallButtons,
  154.                                         MUIA_SpeedBar_Sunny,c->Flags & MUIV_SpeedBarCfg_Sunny,
  155.                                         TAG_DONE);
  156.                         }
  157.  
  158.                         if (sigs)
  159.                         {
  160.                             sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  161.                             if (sigs & SIGBREAKF_CTRL_C) break;
  162.                         }
  163.                     }
  164.  
  165.                     MUI_DisposeObject(app);
  166.  
  167.                     res = RETURN_OK;
  168.                 }
  169.                 else
  170.                 {
  171.                     printf("%s: can't create application\n",argv[0]);
  172.                     res = RETURN_FAIL;
  173.                 }
  174.  
  175.                 if (dto) DisposeDTObject(dto);
  176.                 CloseLibrary(MUIMasterBase);
  177.             }
  178.             else
  179.             {
  180.                 printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  181.                 res = RETURN_ERROR;
  182.             }
  183.  
  184.             CloseLibrary(DataTypesBase);
  185.         }
  186.         else
  187.         {
  188.             printf("%s: can't open dtatypes.library ver 37 or higher\n",argv[0]);
  189.             res = RETURN_ERROR;
  190.         }
  191.  
  192.         FreeArgs(ra);
  193.     }
  194.     else
  195.     {
  196.         PrintFault(IoErr(),argv[0]);
  197.         return RETURN_FAIL;
  198.     }
  199.  
  200.     return res;
  201. }
  202.  
  203. /***********************************************************************/
  204.